<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <body>

        <ui:composition template="./updateLottery.xhtml">

            <ui:define name="tabContent">
                <h:form>
                    <p:panel>
                        <h:panelGrid columns="2">
                            Tỉnh quay* <p:inputText value="#{lotteryLinkBean.selected.city}" required="true" requiredMessage="Bạn chưa nhập tên tỉnh"/>
                            Ngày mở thưởng*
                            <p:selectManyCheckbox value="#{lotteryLinkBean.selectedDays}">
                                <f:selectItem itemLabel="Thứ 2" itemValue="2" />
                                <f:selectItem itemLabel="Thứ 3" itemValue="3" />
                                <f:selectItem itemLabel="Thứ 4" itemValue="4" />
                                <f:selectItem itemLabel="Thứ 5" itemValue="5" />
                                <f:selectItem itemLabel="Thứ 6" itemValue="6" />
                                <f:selectItem itemLabel="Thứ 7" itemValue="7" />
                                <f:selectItem itemLabel="Chủ nhật" itemValue="1" />
                            </p:selectManyCheckbox>
                            Địa chỉ web* <p:inputText value="#{lotteryLinkBean.selected.link}"/>
                            Pattern* <p:inputText value="#{lotteryLinkBean.selected.pattern}"/>

                            <p:commandButton ajax="false" rendered="#{!lotteryLinkBean.edit}" value="Thêm mới" action="#{lotteryLinkBean.create()}"/>
                            <p:commandButton ajax="false" rendered="#{lotteryLinkBean.edit}" value="Sửa" action="#{lotteryLinkBean.edit()}"/>
                        </h:panelGrid>
                    </p:panel>
                </h:form>
                <br/>
                <h:form>
                    <p:dataTable  value="#{lotteryLinkBean.list}" var="link"
                                  paginator="#{lotteryLinkBean.list.size() > 20}" rows="20">
                        <p:column headerText="Tỉnh" sortBy="#{link.city}">
                            #{link.city}
                        </p:column>
                        <p:column headerText="Ngày quay" sortBy="#{link.time2Open}">
                            #{link.time2Open}
                        </p:column>
                        <p:column headerText="Địa chỉ web" sortBy="#{link.link}">
                            #{link.link}
                        </p:column>
                        <p:column headerText="Pattern" sortBy="#{link.pattern}">
                            #{link.pattern}
                        </p:column>
                        <p:column headerText="Hành động">
                            <p:commandButton title="Sửa" ajax="false" icon="ui-icon ui-icon-pencil" action="#{lotteryLinkBean.prepareEdit()}">
                                <f:param name="id" value="#{link.id}"/>
                            </p:commandButton>
                            <p:commandButton title="Xóa" ajax="false" icon="ui-icon ui-icon-cancel" action="#{lotteryLinkBean.remove()}">
                                <f:param name="id" value="#{link.id}"/>
                            </p:commandButton>

                        </p:column>
                    </p:dataTable>
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
